<template>
  <view class="center">
    <view class="bg center">
      <view class="bg-radius"></view>
      <view class="logo" @click="goLogin" :hover-class="!login ? 'logo-hover' : ''">
        <template v-if="isLogin">
          <image class="logo-img" :src="userInfo.avatarUrl"></image>
          <view class="logo-title">
            <text class="uer-name">{{ userInfo.userName }}</text>
          </view>
          <view class="count">
            <view class="count-item">
              <text class="count-item-num">{{ userInfo.prizeTotal || 0 }}</text>
              <text class="count-item-text">我的红包</text>
            </view>
            <view class="count-item">
              <text style="margin-top: 5px">|</text>
              <text>|</text>
            </view>
            <view class="count-item">
              <button type="default" class="count-item-btn" text="去提现" @click="handlePay">
                去提现
              </button>
            </view>
          </view>
        </template>
        <view
          v-else
          class="register"
          style="padding-top: 200rpx; font-size: 20px"
          @click="toRegister"
        >
          <u-button type="primary" text="注册用户"></u-button>
        </view>
      </view>
    </view>
    <!-- <view class="bg-gray center">
      <view class="center-nav margin-top">
        <view class="center-nav-title">
          <text>我的订单</text>
        </view>
        <view class="center-nav-content">
          <view class="center-nav-item" v-for="(nav, index) in navs">
            <text class="center-nav-item-icon">{{ nav.icon }}</text>
            <text class="center-nav-item-text">{{ nav.text }}</text>
          </view>
        </view>
      </view>
    </view> -->
    <view class="center-list" v-if="isLogin">
      <view class="bg-gray" style="height: 20rpx"></view>
      <!-- <view class="center-list-item border-bottom" @click="handlePay">
        <u-icon name="red-packet-fill" size="20"></u-icon>
        <text class="list-text">红包提取</text>
        <text class="navigat-arrow">&#xe65e;</text>
      </view> -->
      <view class="bg-gray" style="height: 20rpx"></view>
      <view class="center-list-item border-bottom" @click="handleDelete">
        <u-icon name="calendar" size="20"></u-icon>
        <text class="list-text">已删除作品</text>
        <text class="navigat-arrow">&#xe65e;</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      login: false,
      avatarUrl: '../../static/girl.jpg',
      uerInfo: {},
      count: [
        {
          num: 5,
          text: '我的红包'
        }
      ],
      customStyle: {
        witdh: '20px', // 注意驼峰命名，并且值必须用引号包括，因为这是对象
        color: 'red'
      },
      navs: [
        {
          icon: '\u{e602}',
          text: '待付款'
        },
        {
          icon: '\u{e601}',
          text: '待发货'
        },
        {
          icon: '\u{e603}',
          text: '待收货'
        },
        {
          icon: '\u{e604}',
          text: '待评价'
        },
        {
          icon: '\u{e60a}', //原代码：&#xe60a;
          text: '退款'
        }
      ]
    }
  },
  computed: {
    userInfo() {
      return this.$store.getters.userInfo
    },
    isLogin() {
      return this.$store.getters.token
    }
  },
  onShow() {
    if (this.isLogin) {
      this.$store.dispatch('getUserInfoIsLogin')
    } else {
      this.$store.dispatch('getUserInfo')
    }
  },
  methods: {
    goLogin() {
      if (!this.login) {
        console.log('点击前往登录')
      }
    },
    toRegister() {
      uni.navigateTo({
        url: '/pagesSub/userCenter/register'
      })
    },
    handleDelete() {
      uni.navigateTo({
        url: '/pagesSub/userCenter/myFile'
      })
    },
    handlePay() {
      uni.navigateTo({
        url: '/pagesSub/userCenter/payFor'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@font-face {
  font-family: texticons;
  font-weight: normal;
  font-style: normal;
  src: url('https://at.alicdn.com/t/c/font_4218190_6debofuo8gh.ttf?t=1701960489041')
    format('truetype');
}

page,
view {
  display: flex;
}

.center {
  flex-direction: column;
}
$head-color: #fff;
$white-color: #fff;
$main-color: #333;
$radius: 0rpx;
$border-color: #efefef;
$color-1: #007aff;
$color-2: #4cd964;
$color-3: #f0ad4e;
$color-4: #dd524d;
$list-item-height: 100rpx;
$list-margin: 20rpx;
$width: 100vw;
$head-height: 550rpx;
$head-width: 120vw;
$margin-left: -60vw;
.bg {
  width: 100vw;
  height: 435rpx;
  background-color: #fc7110;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;

  .bg-radius {
    background-color: $head-color;
    border-top-left-radius: 50%;
    border-top-right-radius: 50%;
    width: $head-width;
    height: $head-height;
    box-sizing: border-box;
    position: absolute;
    left: 50%;
    margin-left: $margin-left;
    top: 150rpx;
    z-index: 8;
  }
  .logo {
    background-color: transparent;
    border-top-left-radius: 50%;
    border-top-right-radius: 50%;
    width: 100vw;
    box-sizing: border-box;
    flex-direction: column;
    align-items: center;
    position: absolute;
    left: 0;
    top: 70rpx;
    z-index: 9;

    .logo-img {
      width: 140rpx;
      height: 140rpx;
      border-radius: 50%;
      border: solid 10rpx #efefef;
    }

    .logo-title {
      height: 150rpx;
      flex: 1;
      align-items: center;
      justify-content: space-between;
      flex-direction: row;

      .uer-name {
        height: 60rpx;
        line-height: 60rpx;
        font-size: 34rpx;
        color: #333;
      }
    }

    .count {
      margin: 30rpx auto 0rpx;
      text-align: right;
      width: $width;
      display: flex;
      align-items: center;
      .count-item {
        flex-direction: column;
        flex: 1;
        text-align: center;
        align-items: center;

        .count-item-num {
          color: $main-color;
          font-size: 36rpx;
          text-align: right;
          font-weight: 500;
        }
        .count-item-text {
          color: $main-color;
          font-size: 28rpx;
          text-align: right;
          font-weight: 400;
          margin-top: 10rpx;
        }
        .count-item-btn {
          color: $main-color;
          // font-size: 28rpx;
          text-align: left;
          height: 60rpx;
          margin-left: 20rpx;
          font-size: 26rpx;
        }
      }
    }
  }
}
.center-list {
  background-color: #ffffff;
  margin: 0 auto $list-margin;
  width: $width;
  flex-direction: column;
  border-radius: $radius;

  .center-list-item {
    height: $list-item-height;
    width: 100%;
    box-sizing: border-box;
    flex-direction: row;
    padding: 0rpx 20rpx;
    display: flex;
    align-items: center;

    .list-icon {
      width: 40rpx;
      height: $list-item-height;
      line-height: $list-item-height;
      font-size: 45rpx;
      color: #4cd964;
      text-align: center;
      font-family: texticons;
      margin-right: 20rpx;
    }
    .color-1 {
      color: $color-1;
    }
    .color-2 {
      color: $color-2;
    }
    .color-3 {
      color: $color-3;
    }
    .color-4 {
      color: $color-4;
    }

    .list-text {
      height: $list-item-height;
      line-height: $list-item-height;
      font-size: 32rpx;
      color: #555;
      flex: 1;
      text-align: left;
    }

    .navigat-arrow {
      height: $list-item-height;
      line-height: $list-item-height;
      width: 40rpx;
      font-size: 30rpx;
      color: #999;
      text-align: right;
      font-family: texticons;
    }
  }
  .border-bottom {
    border-bottom-width: 1rpx;
    border-color: $border-color;
    border-bottom-style: solid;
  }
}
.center-nav {
  background-color: #ffffff;
  padding-top: 1rpx;
  margin: 20rpx auto $list-margin;
  width: $width;
  flex-direction: column;
  border-radius: $radius;

  .center-nav-title {
    padding: 25rpx 30rpx;
    font-size: 34rpx;
    color: #333;
    font-weight: 400;
    border-bottom: solid 1rpx $border-color;
  }
  .center-nav-content {
    height: 180rpx;
    display: flex;
    align-items: center;
    .center-nav-item {
      flex-direction: column;
      flex: 1;
      text-align: center;

      .center-nav-item-icon {
        color: #333;
        font-size: 48rpx;
        font-weight: 500;
        font-family: texticons;
      }
      .center-nav-item-text {
        color: #666;
        font-size: 30rpx;
        font-weight: 400;
        margin-top: 15rpx;
      }
    }
  }
}
.margin-top {
  margin-top: 20rpx;
  min-height: 230rpx;
}
.bg-gray {
  background: #f4f4f4;
}
</style>
